package com.oos.zone.annotation;

import com.oos.zone.aware.AwareBeanPostProcessor;
import com.oos.zone.properties.WechatMpConfigProperties;
import com.oos.zone.scan.WechatMpComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import javax.annotation.Nonnull;
import java.lang.annotation.*;
import java.util.Arrays;
import java.util.Collections;

/**
 * 功能描述：微信公众号相关 ImportSelector
 *
 * @author 拓金辉
 * @version 1.0
 * @date 2021-08-12 15:28:17
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Inherited
@Import({EnableWechatMpSupport.InnerImportSelector.class})
public @interface EnableWechatMpSupport {

    class InnerImportSelector implements ImportSelector {

        @Override
        public String[] selectImports(@Nonnull AnnotationMetadata importingClassMetadata) {

            return Collections.unmodifiableList(
                    Arrays.asList(
                            WechatMpConfigProperties.class.getName(),
                            AwareBeanPostProcessor.class.getName(),
                            WechatMpComponentScan.class.getName()
                    )
            ).toArray(new String[0]);

        }

    }

}
